﻿using Anderson.NetLobby.Client;
using UnityEngine;
using UnityEngine.UI;

public class DemoClient : MonoBehaviour {

    public string host = "127.0.0.1";
    public int port = 8000;
    public Button ConnectButton;
    public InputField InputFieldFrameCount;

    private NetLobbyClient client;

    private void Start()
    {
        ConnectButton.onClick.AddListener(OnConnect);
        ConnectButton.interactable = true;

        client = new NetLobbyClient(host, port, "aaa", new UnityLogger());

        client.heartEvent.AddListener(OnHeart);
    }

    void OnHeart(long frameCount)
    {
        InputFieldFrameCount.text = "" + frameCount;
    }

    private void OnDestroy()
    {
        client.Disconnect();
    }

    void OnConnect()
    {        
        client.Connect();
    }

}
